Minecraft does not natively support the SteamDeck controller. However, mods are always here to save the day.
I recommend using PrismLauncher to launch the game. It has first class modding support, and is just easier to use with modding than the official launcher.
Steam Button > Power > Switch to Desktop
This will switch you to desktop mode. Once desktop mode has loaded, click the steam deck logo in the bottom left of the screen to open the "start menu".
Steam Button + x
to load the keyboard, and search for "Discover", clicking it once it has been found.
In Discover, use the keyboard again to search for "Prism Launcher", and when it has been found, install it. Should take a minute or two.
You should now be able to find Prism Launcher in the "start menu". If you cannot, restart the deck, and re-enter desktop mode afterwards.
Launch Prism Launcher, it should get you to configure language etc first. If it asks you to select a Java version, select "17" (or whatever the highest is).
Click on accounts (1) and manage accounts. It will open the account manager screen. Add a Microsoft account (2) (or Mojang, if you haven't migrated), and follow its sign in steps.
When you have signed in, you can create a new instance. There is a large "Add Instance" button. Click it. It will open the new instance dialog.
Make sure to select Fabric (2). Going with the default (starred) options should be good. Then press OK, which should create the instance for you.
Right click on the new instance you just made, and select "Edit Instance" (1).
Switch to the "Mods" tab, and click "Download Mods" (2).
Under the Modrinth tab, search for "Fabric API" and "Midnight Controls". Select each for download, then click "Review and Confirm", then "OK". It should install the mods for you.
You can now launch the instance. It should launch into the game. All going well, you should now be able to play the game entirely with the controller.
You can change controller settings in game by going:
Options > Controls
then clicking the controller icon next to Key Binds
.