For macOS 13, Ventura... Go to the Apple menu, then System Settings. Click "Desktop & Dock". Turn off the option "Show recent applications in Dock".
For systems before macOS 13, Ventura... Go to the Apple menu and choose "System Preferences". Choose the "Dock" preference panel. Uncheck the box next to "Show recent applications in Dock".