You must have broken either the snap on the underside of the key cap itself, and/or broke the nub on the scissor mechanism. Or perhaps you did not reattach the metal stabilizer bar correctly.
FYI, it is not easy to remove the key cap on the M-series Macs (or the Intel Macs from Late 2019-2020) without damaging the key cap and/or the scissor mechanism.
Theoretically Apple or an AASP can order a Key Cap Kit and a Scissor Kit, but I'm not sure most techs are even aware this is a possibility. It would not be cheap because the Kit includes one key cap or scissor mechanism for every key on the keyboard.....easily $50+ for each Kit (before any labor costs). Most posts on this forum seem to indicate that Apple & AASPs will only quote for replacing the entire Top Case/Keyboard Assembly which is even more expensive.
If your laptop is eligible for Apple's Self Repair Program, perhaps you can order a Key Cap Kit and/or Scissor Kit......or perhaps Apple will only offer a more difficult & expensive Top Case/Keyboard Assembly. You do need to make sure to be very careful when installing a key cap since you need to insert the one side & press down on the other to clip it in place. Do it wrong & the key cap will be damaged & you will need another $50+ Key Cap Kit to try again. FYI, if the Scissor Mechanism is damaged, then that is very difficult to remove & install on the M-series Macs even for me a tech with decades of experience (the older Macs were much easier than the new ones for replacing scissor mechanisms & key caps).
Some third parties do sell key caps & scissors (perhaps individually), but you need to make 100% you are getting the correct one to match your laptop exactly since Apple has had many different ones over the years where they look almost identical.