How to copy codes from a arduino of an cnc machine

You can download the compiled code from an Arduino using AVRDUDE. So long as the originator hasn't locked it, which is pretty rare.

If you have identical hardware then you can upload this binary to as many copies as you want. You can even keep this as a backup of the original firmware while you try uploading other programs to the original Arduino.

However you cannot recover the original C++ code from the Arduino. If the original programmer won't sell or give it to you then you have no way to make modifications.