All doubters and then the same fans that tend to show up each time this comes up to blame user, cable, firmware, brand, age, hub, etc. (in other words, anything & everything other than Apple) can just do a simple search for "macOS unexpected ejection" and "macOS disk not properly ejected" to find MANY pages of matches mixed in among potential/hopeful remedy articles like "10 ways to fix..." which generally turn out to be red herrings. There's far too many matches for it to be any one user, any one cable, any one bit of firmware, etc. There's only ONE common variable in all of that experience.
Anyone who digs in thinking they can crack this problem- as I did for WEEKS- will eventually read enough posts by people on Macs with stable externals BEFORE upgrading to Big Sur or newer, encountering this issue, needing stable drives more than new bells & whistles so they went to the trouble of downgrading macOS again and the problem immediately ceased. That SCREAMS where the cause lies to me.
As I mentioned it is not ALL drives, ALL enclosures, etc. But it's definitely a problem for more than "a few rare cases" as some OS problems are often acknowledged. While not immune, SSDs seem to fare better than HDDs. RAID enclosures- both SSDs and HDDs- seem to be most likely to encounter this problem.
Back to point: if one relies on external storage to store core libraries like photos/music/video (as I do myself), be prepared for occasional unexpected ejections which can result in the core apps creating a new library on the internal drive and then you seem to have lost all of the applicable media. You haven't, but now you may need to merge new library with old one and reassign where the core app is supposed to look for the media... again.
If someone is buying a new Mac and wants to avoid this hassle, pay up (far too much relative to market rates) for best guess core app storage needs in years 7-10 so you don't have to relocate photos or music, etc OUT to an external. macOS really likes macOS apps working with internal storage. One can get around that but you have to jump through maintenance hoops to persist the alternative solutions.