For problems involving only conservative forces, we can now quite easily derive conservation of mechanical energy. We have and . Together this says that or . This says that doesn't change, so it must be constant:
We call the total mechanical energy . We've just shown that does not change in time.
Conservation of energy is more general than this however. If you have non-conservative forces such as friction, some mechanical energy goes into heat, that is mechanical motion at a molecular level. If you were to add in this extra energy, you'd see that energy is still conserved. The total energy, is always conserved. That's a general principle of physics. The fundamental reason for this has to do with the simple observation that the fundamental laws of physics don't change with time. If you do an experiment on an electron on Tuesday, you'd expect to get the same results on Friday. Unless of course it's Friday the 13th, when no experiments work.
This simple idea that the laws of physics don't change with time, leads to conservation of energy. If you take more advanced physics classes, you'll eventually see why that's so.