Can someone please explain why the safari window keeps moving every time that I open a new Safari window as show in the screenshot. It will not stay aligned to the dock no matter how many times I move it back. Any help would be appreciated.
The only alignments supported are full screen and recently split screen: https://support.apple.com/en-us/HT204948. You can also have multiple desktops and swipe between them.
No app will never align to the dock because if you unpin an app from the dock it will shrink or if you launch an app not in the dock it will grow. The dock changes so there is no dock alignment.
You can make the dock hide or move it to the side to hide the "alignment" issue, or just make Safari bigger and skip the issue.
You can get something like BetterSnapTool and setup a custom alignment.
Just for fun, there is one 'secret' alignment trick that works with most apps: If you drag an app window partly off-screen, then Hide the app, then click on it in the dock, the window will reappear aligned to the side and/or corner of the screen.