Have you already tried standard tools available in ArcGIS?
Are you looking to create a local copy (Geodatabase Feature class) of the map service?
In that case, you need to enable Feature Access capability with EXTRACT option enabled while publishing the Map service in ArcGIS Server.
Does this mean that services published from layers stored file geodatabase?
Do you need to have the data stored in enterprise geodatabase to have its extractable from its service? Even though, the extract tool is not working as shown in the screenshots below
No such command is available for the service
I just finished building a web page which uses the Extract Operation to prepare a download for the user. It can be configured for your own data in Arcgis Online and is of course free to use. Have a look at my page and the instructions:
I think you can download the layers only if they are published as hosted feature layers.
You will require Portal for ArcGIS (federated and containing a hosted server) or ArcGIS Online to achieve the desired task.