cd ~ changes to the home-directory of the actual user. Where the home-directory is, is configured in the passwd-map (or -file (/etc/passwd)).
If you're working as root, cd ~ brings you to the home-directory of the user root. Which is /root in most cases.
If you're working as user1 and that users home-directory is defined as /home/user1 in /etc/passwd/, cd ~ brings you to /home/user1.
~[user] is just some shell-shortcut (in bash and some other shells, not all of them). If you leave out the user, internally the actual user is substituted.
So, as root you could do cd ~user1 and that would change the directory to /home/user1.
~is synonymous with the home directory in Ubuntu" – But the home directory is almost always something other than/home. For me it's/home/kamiland for root it's/root. – Kamil Maciorowski Aug 01 '23 at 06:41