What are some of the reason for file locks

in the database oc_file_locks , sometimes there thousands of record , is there a way to see why this happens ?

No idea. But perhaps you can optimize Nextcloud with using cron.php instead of AJAX if not yet configured.

https://docs.nextcloud.com/server/18/admin_manual/configuration_server/background_jobs_configuration.html

why cron job will help?
which type of cron job i have to run, or only run cron.php is ok ?

Only “cron.php”. Perhaps it solves your problem. Test both once and look for differences.

sudo -u www-data php cron.php

and

sudo -u www-data php occ system:cron

https://doc.owncloud.com/server/admin_manual/configuration/server/background_jobs_configuration.html