Dynamically stable electron bunches in beam interaction with an electromagnetic wave packet