How Do I Hide Recently Used Apps From The Mac Dock?
Starting in macOS Mojave, Apple introduced a new feature for the Dock that shows three recently used applications alongside the items that permanently appear in the Dock. This feature mirrors the behavior found on the iPad.
In order to hide the recently used apps from the Dock on your Mac, first launch the System Preferences app (it can be found in the Apple menu on the top left of your screen). Go to the Dock preference panel then uncheck the option that reads "Show recent applications in Dock". Recent apps will then stop appearing in the Dock.