Click the Start button, find your app in the list, right-click it, and select More > Pin to taskbar (Windows 10) or Show more options > Pin to taskbar (Windows 11).

Pinned icon opens wrong program or does nothing. Cause: The original desktop shortcut had command-line arguments or a specific working directory that you lost. Fix: Create a new shortcut to the .exe including arguments, then pin that new shortcut’s target.

Actually, simpler:

Go to Settings > Personalization > Taskbar > Taskbar behaviors and ensure "Select the far corner of the taskbar to show the desktop" is checked.