As described, it is very likely that the magnet embedded in the screen cover is incorrectly positioned. Less likely, the iPad's hall-effect sensor that detects proximity of the screen cover when closed, has a fault.
The automatic lock/unlock function is triggered by proximity of a small magnet embedded in the case cover. The position of the iPad sensor (and hence the case-embedded magnet that interacts with it) is critical - and often differs between iPad models. Many low quality iPad cases/covers of third-party origin may have incorrectly positioned magnets.
Before considering the iPad itself to be at fault, you would be best advised to substitute the case/cover (preferably of Apple origin) and re-test. If the issue is resolved, you have positively identified the source of the issue. If the problem is not resolved, only then consider a problem with the iPad itself.
If the problem is repeatable with an Apple cover, you might then consider seeking assistance from 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