I’m not great at physics and have no knowledge of aeronautics, so this whole chain of reasoning might be wrong.
A plane stays in the air because air is moving over the wings, which generates lift. However, that air is moving because the engine is moving the plane forward. There is no other source of energy. Therefore, some of the engine’s energy is going into keeping the plane in the air, and some is going into accelerating it forwards, or keeping it at the same speed (fighting air resistance).
Therefore, if the plane points straight up, the engine should be able to support it hovering in the air. If it didn’t have enough power to fight gravity when pointing straight up, it wouldn’t have enough power to fight gravity when moving horizontally, either.
(Okay, some older engines only worked in certain orientations, but I don’t think that’s a problem for jet aircraft, or any aircraft built after WWII.)
So why can only certain planes fly vertically?
You basically already answered it yourself. The wings provide the lift needed to overcome gravity. The wings can provide this lift because the plane is moving through the air, which it does via the engines propelling it forward. At a certain velocity enough lift is generated to overcome gravity and the plane can take off.