A lot percentage of it is due to how storage is displayed in that menu.
Previously total storage was displayed in metric units (gigabyte = 1000 MB), while everything else in the storage menu was displayed in binary units (gibibyte = 1024 MiB). That mean your total used storage would only add up to 476 GiB (=512GB). Samsung added the difference (35 GB) to system to it’d add up correctly to 512 “GB”.
In OneUI 6, everything in the storage menu is displayed in metric units so there’s no ‘conversion loss’ to account for. You can confirm this by comparing a file shown in Samsung’s storage menu to the same file in Windows, Linux or a 3rd party Android app. Those OS’s will usually use binary units, so you’ll see a difference in file size.
The additional 10GB difference is due how the system partition size is calculated, which is normally flawed in Android. Samsung fixed this in OneUI 6.
I tested it after 1, 2, 3, 4, 7 and 10 rotations with my base S22 on OneUI 5 and base S23 on OneUI 6.