Is the iPad within a fitted case? If yes, ensure that the entirety of the iPad's screen bezel is free of any obstructions - as the bezel contains ambient light sensors. Similarly, some types of screen protector, if fitted, can cause issues.
Having eliminated these factors, if unresolved, try a forced-restart of your iPad - as this will often clear an isolated software issue:
Force restart iPad (models with Face ID or with Touch ID in the top button)
If your iPad doesn’t have the Home button, do the following:
- Press and quickly release the volume button nearest to the top button.
- Press and quickly release the volume button farthest from the top button.
- Press and hold the top button.
- When the Apple logo appears, release the top button.

Force restart iPad (models with the Home button)
Press and hold the top button and the Home button at the same time. When the Apple logo appears, release both buttons.

If the problem persists after the restart, you may have a hardware fault that will require further investigation and potentially repair. You would be best advised to visit the Genius Bar at your local Apple Store or Apple Authorised Service Provider (AASP) - where the technicians will be able to test and assess your iPad.
Genius Bar Reservation and Apple Support Options - Apple