Let a ball fall freely to the ground, hit and bounce back. Assume mass of the ball does not change during this.
Since momentum is conserved in all collisions, $p_i = p_f$
In this example, the system consists of the earth and the ball.
Taking earth as the frame of reference, this equation becomes: $m_e *0 + m_iv_i = m_e*0+m_fv_f$, where $m_i$ and $m_f$ the initial and final masses of the ball respectively, while $v_i$ and $v_f$ being the initial and final velocities.
The velocity of earth is considered $0$ since it is not moving with respect to our frame of reference.
Assuming the ball does not lose mass during the collision further simplifies the equation to this: $m_iv_i = m_iv_f \implies v_i=v_f$
But normally when ball fall into ground and collide, we observe that some of its energy is lost as heat and sound leading to a decrease in its Kinetic Energy.
Since we assumed that the mass of the ball does not change during collision, and found also velocity does not change from above, $\frac{1}{2}m_iv_i^2 = \frac{1}{2}m_fv_f^2$, because:
$m_i=m_f$, $v_i=v_f\implies v_i^2 = v_f^2$
But this contradicts our observation. So one of the steps above must be wrong. Please help me identify which step is the source of contradiction.
This question is related to but not exactly same as: Why is momentum conserved in an inelastic collision and kinetic energy is not conserved? and How can momentum but not energy be conserved in an inelastic collision? Because, the question and explanations are more generalized and I understand the answers in those cases.