a) In any closed system, momentum is conserved. The momentum of a body is calculcated by multiplying the mass and velocity of the body together.
If you have two bodies colliding (lets call them body x and body y), their total momentum is calculated by just adding them together.
Momentum is considered conserved if the momentum before is the same as the momentum after. In your first example, the total momentum of the blue and green object before the collision is 40`(kg*m)/(s)` . Afterwards it is still 40`(kg*m)/(s)` . Thus, momentum is conserved.
b) Once you understand that 'conserved' means 'the same total before and after', you can also see that in your first example, kinetic energy is conserved because the total kinetic energy before and after are the same.