What's going on?
When a water bottle is flipped, it gains some angular momentum, which just means the bottle has some rotational energy. Any object that has angular momentum will keep rotating unless something slows it down, like the friction of a hand on a flying frisbee. Even if your flipped bottle landed straight on the table, angular momentum dictates that the bottle should keep trying to spin — and fall over. How does the bottle stay upright after it's been flipped, then?
Water is free to flow inside the bottle, and as the bottle rotates, some of this water slides around and hits the inside of the bottle, absorbing much of the bottle's angular momentum. At this point, the bottle is flipping very slowly, and it falls straight down due to gravity. If you've timed everything right, the bottle will land straight on the table, and without any angular momentum to knock it over, it'll stay upright.
Why does an oil-filled bottle flip and land easily, but not a syrup-filled bottle? The key here is the viscosity of the liquid - how easily the liquid flows. In fact, the trick will only work if it contains a liquid that can quickly flow around (which means a liquid with low viscosity). A flipped bottle full of oil will slow its own rotation as the slippery oil slides around inside, but a flipped bottle full of syrup will keep spinning and knock itself over when it lands, because syrup doesn't flow easily.
Lastly, you may have noticed that this trick doesn't work when the bottle has too much or too little water inside. This is because the water needs to have enough mass to counter the angular momentum of the spinning bottle, without being so heavy that the bottle's center of gravity moves high up towards the bottle's cap. A high center of gravity will make the bottle more prone to tipping over, making a nearly-full water bottle much harder to successfully flip than a bottle that's only 1/3 full.