Time-dependent kinetic analysis of trapped electrons in a magnetically expanding plasma