This is caused by the new "Recent Apps" feature introduce by Apple in Mojave. Please follow the below steps to disable this behaviour:
- Open System Preferences (Apple menu > System Preferences)
- Click on Dock.
- The last setting in the Dock preferences is a checkbox for Show recent applications in Dock. It’s checked by default. Clear the box to turn it off.
- Close the preferences window.