Prevent switching workspaces when clicking on dock icon
Open Terminal.app, then run the following commands.  

Change the default workspace preference:  


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


Next, restart the Dock with this command:


  killall Dock


References:
How can I disable auto-switching desktops?
Disable Space switching on Command-Tab