In an isolated system, or one where there is no energy coming in or going out, total energy is always conserved, though it may change form. If there is no friction, total momentum is also conserved.
For a body with mass m moving at a velocity v, the momentum is m*v. When two bodies collide, momentum is conserved irrespective of whether it is an elastic collision or an inelastic collision. In an elastic collision, two bodies with a mass m1 and m2 initially moving at velocities u1 and u2 collide and their velocity changes to v1 and v2.
If friction can be ignored, m1*u1 + m2*u2 = m1*v1 + m2*v1
Similarly for an inelastic collision if friction can be ignored, the two bodies stick to each other after collision. Here we see that m1*u1 + m2*u2 = (m1 + m2)*V, where we is the final velocity of the both the bodies after collision.
When two bodies collide, the total initial kinetic energy of both the bodies is equal to the total final kinetic energy of both the bodies, if friction can be ignored. Even if that is not the case, total energy is conserved; only a part of it is converted from kinetic energy to heat.