You may want to check the T&C. In every Microsoft licence agreement I've ever seen, the ability to use a discount or program associated with an employer you're no longer employed by, ceases to exist the moment you leave them. The old Home Use Program (HUP) was a good example of this. Just because it works, doesn't mean it is legal.
Nothing illegal happening whatsoever.
The old home use program (where a home copy was free and for a single person/computer) had different terms. Home use was tied to (part of annual cost of) the employers ongoing license agreement which is why you needed a valid license key and you couldn't change the embedded company name. Those copies were supposed to be deleted when you moved on.
I've not seen a 365 version of this type of offering, but given employer supplied laptops are ubiquitous these days and employer policies allow some personal use of said laptops there probably isn't a great need.
The current 365 personal pricing plan I have, is not subsidised by a specific employer. Microsoft have essentially established a preferred/premium sales channel which seeks its direct customers by targetting employees of its corporate clients, at better than their RRP/public price. The original sign-up link (i should not have typed code) provided is the same whether you work at one of the big banks or a not for profit or a government department.
It's a cheap sales channel, as corporate customers do the marketing by posting link on their employee discount page and individuals opt in. They get to keep the personal customers even if the employer they sourced the sales lead from ceases to exist or be a corporate customer.
The email address used to create account is personal as is the credit card that pays for the account. Microsoft know where the referral came from but the purchase is not tied to employment, no mention of employer in the account set up process or terms.
Microsoft have since chosen to continue to offer me the preferred customer pricing. There is nothing in the renewal terms mentioning continued employment or a specific company which makes sense as no employer is subsidising any aspect of the account.
I also get emails from Microsoft reminding me it comes with provision for 5 users and as I'm only using 2, I could add 3 other family or friends (it doesn't even have the restriction of same household).
If Microsoft were selling personal subscriptions tied to continued employment they would need to refund the unused portion of any annual subscription to individuals if employment ceased and they lost access to 365. Something that would likely cost them more to police than the revenue it generates and make customers less likely to sign-up again with next employer.