A common example question we get in exams involves something like the following: Calculate the velocity of a block with mass X$kg$, when it is struck by a bullet of mass Y$kg$ travelling at Z$m/s$. The block is initially at rest and the bullet embeds into the block during the collision.
To solve this we usually find the momentum of the bullet $(Pkg/m/s = Ykg * Zm/s)$ and then find the velocity of the block/bullet combination by reversing it: $(Am/s = Pkg/m/s / (X+Y)kg)$.
We will then be asked to calculate if the collision is elastic or inelastic, which we will do by calculating the mechanical energy of the bullet before, and the mechanical energy of the bullet/block combination after the collision.
My question is how is it possible to have a different energy before and after? We frequently end up with different energies before and after, however nowhere in our equations do we take into account loss of energy in the form of friction, sound, heat etc.
TL;DR: How do we get different before/after energies in a collision without taking into account external energy loss? Is the equation wrong?