In Australia too, Apple has gotten in trouble for their "error 53" technical measure to discourage third party repairs and not repairing devices that had that error https://www.accc.gov.au/media-release/accc-takes-action-agai...
This follows an earlier infraction over refusing to repair faults after a year without AppleCare https://www.crn.com.au/news/apple-agrees-to-two-year-warrant...
I've done user-upgrades of the RAM on all my desktop Macs, and subsequently had repairs done under warranty here in the UK. Never had a problem and one at least two occasions the Apple engineers knew about the RAM upgrades. In fact the last HD replacement on my iMac was done free even out of warranty, I think because I mentioned I'd had it happen before on a previous Mac.
At least in the US (and presumably in the EU which is much better about this sort of stuff) this is not legal. You can upgrade it on your own and Apple still has to honor the warranty.
https://www.ftc.gov/news-events/press-releases/2018/04/ftc-s...