If you use a move that boosts a stat that is already at its max, the move will just fail and it will that that it can't go any higher.
If you lost the boosts, you either switched out or used a move that lowered your stats, or your opponent used a move that lowered your stats.
Here is a replay of me testing it on Showdown with myself.
Source: knowledge and testing
Hope I helped.