Question: I'm going to a concert to Vienna on Saturday (two days). I just realized that there aren't any trains back to my home in the night so I'd have to wait til the morning until the first train leaves again (5.43 AM).

I don't know when the concert will end, but expect it to be somewhere between midnight and 2 AM. 

Now, I don't want to spend 40 € on a hotel room, especially when I can only "book in" in the middle in the night and have to leave really early. 

Is there any safe space in Vienna for a young woman to stay for a couple of hours in the middle of the night? I don't need to sleep, I just don't want to get raped. 
Are train stations safe there? Or are there any cafés which are open 24/7? MacDonalds?

Answer: 
For 5.8€, you could get a transit day pass that allows for unlimited travel on the transit network, including night buses – (especially) if you take a seat next to the bus operator, you'll definitely be safe, and you'll also see some more of Vienna.
As you are staying on a weekend, there will be plenty of bars, clubs and other entertainment locations open till the early morning. Some of them may be loud, some quiet, so you can pick depending on what you are likely to be in a mood in after the concert.

Here's an english website listing many options: <https://www.wien.info/en/lifestyle-scene/nightlife>

Note that in general, Vienna is considered a very safe city. So you should most likely be fine no matter where you stay, but as everywhere else, a public place is a good option.