I've had this happen before to a coauthor (they were neither the first nor last author in a list of ~6), who contacted the editor replying that obviously they couldn't review the paper.
We had a little chuckle over it and moved on. Probably the editor was a bit embarrassed by their error, otherwise no harm done. I presume they used a list of previous reviewers the journal had contacted on the topic of our paper and missed that they were actually an author on the submitted work, or maybe they made a cognitive switch and started typing a name they just read was an author instead of the reviewer they intended to type.
I think the other answers are being a bit harsh towards the editor: they clearly made a mistake, but no reasonable author would ever review their own paper and this shouldn't cause any real problem. No, this is not a usual practice, but it happens at low frequency when people are busy. It's good you are producing enough work to have it happen to you or your colleagues twice.
As mentioned in comments, if your subfield practices triple-blind review where the editor is blinded to the identity of the authors then it is even more likely such errors could occur (and be less the fault of the editor) if imprecise software is used to exclude possible reviewers.