How to switch focus to the application that opens the link/file from an email?

I found the solution, albeit it was an answer to a different question. This fixed another problem I was having wherein I had to click on an application in the dock, twice, to switch to it. This is now fixed. I ran the following commands

defaults write com.apple.dock workspaces-auto-swoosh -bool YES

then restart the Dock with the command:

killall Dock