Murphy's Law
If anything can go wrong, it will. However, we as pilots learn to deal with these situations. That is one reason why flying is as safe as it is.
For example, loss of the engine. That can happen. It has happened. We learn to minimize that risk as best as possible at the beginning, by making sure we have enough fuel for our flight, that it is the right fuel, and ensuring the fuel is free of contamination. Hopefully, your instructor conveyed these points to you when he had you turn on the master to check the fuel guages, had you uncap the tanks to check fuel visually, and had you sump the tanks to check for color and drain off sediment. Also during the preflight, we inspect the prop blades to ensure they are free of nicks, because a blade can fall apart if vibration gets to a nick. If there are nicks, we get a mechanic to dress them out with a file before we start the engine.
Then, on runup, we check the mags to ensure both are operating and neither is grounding. We check carburetor heat to ensure we have an antidote to carb ice. We check for proper power on takeoff (and abort the takeoff if the engine is not developing the proper power). We make sure the fuel is switched on the proper tank(s) for takeoff. We treat the engine carefully during the flight. So, we take great pains to eliminate the possibility of an engine failure in flight beforehand, because the items I enumerated above are the major causes for engine failure in flight.
Despite all this, the engine fails. So, we receive training to deal with it. We learn that the airplane will not fall out of the sky if we lose power. We learn that we will keep flying the airplane at its best rate of glide speed and turn to the most suitable place to land. In the meantime, we'll try to troubleshoot the engine failure. If we cannot get a restart, we will complete the emergency landing checklist, make an emergency landing and survive the catastrophe.
So, yes, if something can go wrong, it will. We do everything in our power to prevent it from happening, such as good preflight planning. But, if something does go wrong, we, as pilots, are trained to deal with it, bearing in mind that safety is always first.
Hope that helps a little. Have fun and best of luck with your training.