Hi @Developer_Providers and welcome to the community forum.
As the error suggests, you need to be connected to mongos to use the sh.enableSharding() command.
From the above command it seems you are trying to use the command from on the shard.
Also, Starting in MongoDB 6.0, this method is not required to shard a collection.
Let us know if you have any further questions.
Regards
Aasawari