Sideways Video and Editing Software

Okay, so I was at a concert. I held my phone in portrait mode, it videoed in landscape so it is 90 degrees rotated. When I rotate my phone it rotates and I can't see it correctly. What did I do wrong? How can I avoid this in the future? What made it do that?

Now, how can I edit on my phone before I upload to you tube? Is there free/cheap software or do I have to do so on my PC and if so, what cheap software?
Can anyone help me with this quandry?

Original thread: https://forums.imore.com/threads/sideways-video-and-editing-software.208938/