Energy conservation applies to motion of bodies moving in conservative fields. In such fields, the field's force inter-converts the energy of particles between its kinetic and potential parts.
If the diagram alludes to a bullet travelling horizontally at the same level as a stationary block at the moment of impact, and its getting stuck in that block, and the block thereafter following a parabolic trajectory under the sole influence of gravity (which is conservative), from an initial position of $(0,h)$ to the final position $(d,0)$$^1$ - then it would be right to think conservation of energy applies.
Or would it? Can you spot where a non-conservative force comes into play?
This dissipative force
friction or any other stop force from the block
is responsible for preventing you from applying energy conservation before and after the bullet-block collision.
Let $v^{[2]}$ be the initial horizontal velocity at $(0,h)$ of any particle that travels the indicated parabola.If the velocity of the bullet pre-collision was $u$, the correct expression for $u$ conserving momentum only, would be
$$u=\frac{m+M}{m}v\tag{1}$$
where $m,M$ are masses of bullet and block, resp.
On the other hand, the expression obtained by assuming energy conservation too, is
$$u=\sqrt{\frac{m+M}{m}}v\tag{2}$$
As you can see, using energy conservation doesn't just give a different answer for $u$, it gives a lesser one.
This is because at $(0,h)$ post collision, energy conservation is thinking "this is all the energy that was there before" when in fact the dissipative force has consumed some. So using this reduced energy to calculate the bullet's initial speed gives a lower answer.
Is this something case specific to this bullet-block system? Not at all. What you have come across is an inelastic collision. In such collisions, energy ends up getting lost and energy conservation doesn't apply.
Note that for inelastic collision, it isn't necessary that the force responsible for eating away some of the initial energy be dissipative i.e. non-conservative.e.g. imagine there was a spring inside the block which helped stop the bullet. Spring force is conservative, yet the bullet-block collision (and not the bullet-block-spring collision) would be treated as inelastic.
The key point here is that there is some binding force that makes the bullet stick to the block. This force consumes a binding energy from the initial configuration. If conservative, this energy can be recovered by breaking apart the system. In your case, since it was probably friction, the binding energy got dissipated as heat and sound.
$^1$ you didn't mention any of this.
$^2$ $v=d\sqrt{g/2h}$, $g$ due to gravity.$