It's not the first time this has happened and in the past it's been a signal from the Moroccan government to the Spanish government that they are not happy about something. Basically, Morocco uses migration as a political weapon to threaten Spain despite Morocco getting lots of EU money to keep their borders secure! See Below
"2021 border incident
Main article: 2021 Morocco-Spain border incident
The main precedent for the 2026 crisis was the May 2021 border incident, during which around 8,000 people entered Ceuta from over the border within two days, most by swimming around the breakwaters, and among whom were numerous unaccompanied minors.[29] That episode followed a diplomatic crisis triggered by Spain's hospitalisation of Brahim Ghali, secretary-general of the Polisario Front, who was treated at the Hospital San Pedro in Logroño due to a case of COVID-19, for which Spain had not issued a prior notice to Morocco.[30][31] The initially limited response of Moroccan security forces was widely interpreted in Spain as a form of diplomatic pressure.[13] It exposed the limits of Ceuta's reception capacity and Spain's dependence on Moroccan border cooperation.[29]
2022 Melilla incident
Main article: 2022 Melilla incident
On 24 June 2022, around 2,000 migrants and asylum seekers gathered in the early hours of the day to cross the Melilla border fence:[32][33] 23 migrants and asylum seekers were killed after a crowd crush during a conflict with Moroccan and Spanish security forces.[34]"