As stated in the documentation for the RESTORE DATABASE
command, using the TO target-directory
option allows you to change the target database directory, but only if you are restoring a database that does not already exist. If the database already exists (as it does in the commands you give above), then specifying this option has no effect.
Keep in mind, too, that the database directory only holds database metadata. The rest of the data (tablespace containers, transaction log files, etc.) may be stored elsewhere on the system. If you need to relocate these files when performing a restore, you either need to use a redirected restore or, if your database is using automatic storage, specify new storage paths.
You can read more about how to perform a redirected restore.