As described, you are perhaps working between your iPad and an external task.
As you have a 2021 iPad Pro, you likely have FaceID enabled. There are two related functions that will determine how long your iPad screen will remain switched-on before the iPad will turn-off the screen (and lock) to conserve power. These are the Auto-Lock and Attention Aware settings...
Auto-Lock will automatically turn-off your iPad screen when the iPad is not being actively used - the time period before this occurring being set in iPad settings:
Settings > Display & Brightness > Auto-Lock - select as required
Keeping this period relatively short (e.g. two or five minutes) helps to ensure that your personal and sensitive information cannot be easily accessed when you are away from your iPad. As long as you are interacting with the iPad, the screen will remain active.
Attention Aware is an additional feature that iPad's with FaceID can actively detect that you are paying attention to the screen (such as reading screen content, but otherwise not interacting by touch with the iPad) - and will keep the iPad active for as long as your attention remains focussed on the iPad. When you stop paying attention to the iPad, the Auto-Lock settings will determine precisely how long the screen will remain active.
Settings > FaceID & Passcode > Attention-Aware Features - set to ON or OFF as preferred
For many, the ideal settings are to keep Attention Aware enabled (i.e., set to ON) with Auto-Lock set to five minutes. If your attention to your task keeps your attention away from the iPad screen for more than five minutes at a time, consider extending the Auto-Lock delay. Be aware that if your select Never, your iPad will not automatically lock and protect your data from unauthorised access.