How could the Egyptian magicians do what God did through Moses? In Exodus when God performed miracles through Moses and Aaron, the Egyptian magicians did the same things that God did, How is that possible ?

The first time:


  Exodus 7:10-13
  
  So Moses and Aaron went to Pharaoh and did just as the Lord
  commanded. Aaron threw his staff down in front of Pharaoh and his
  officials, and it became a snake. Pharaoh then summoned wise men
  and sorcerers, and the Egyptian magicians also did the same things by
  their secret arts: Each one threw down his staff and it became a
  snake. But Aaron’s staff swallowed up their staffs. Yet Pharaoh's
  heart became hard and he would not listen to them, just as the Lord
  had said.


The second time:


  Exodus 7:20-24
  
  Moses and Aaron did just as the Lord had commanded. He raised his
  staff in the presence of Pharaoh and his officials and struck the
  water of the Nile, and all the water was changed into blood. The
  fish in the Nile died, and the river smelled so bad that the Egyptians
  could not drink its water. Blood was everywhere in Egypt.
  
  But the Egyptian magicians did the same things by their secret
  arts, and Pharaoh's heart became hard; he would not listen to Moses
  and Aaron, just as the Lord had said. Instead, he turned and went
  into his palace, and did not take even this to heart. And all the
  Egyptians dug along the Nile to get drinking water, because they could
  not drink the water of the river.


The third time:


  Exodus 8:5-7
  
  Then the Lord said to Moses, "Tell Aaron, 'Stretch out your hand
  with your staff over the streams and canals and ponds, and make frogs
  come up on the land of Egypt.'"
  
  So Aaron stretched out his hand over the waters of Egypt, and the
  frogs came up and covered the land. But the magicians did the same
  things by their secret arts; they also made frogs come up on the land
  of Egypt.


But lastly they couldn't do like Moses:


  Exodus 8:16-19
  
  Then the Lord said to Moses, "Tell Aaron, 'Stretch out your staff
  and strike the dust of the ground,' and throughout the land of Egypt
  the dust will become gnats." They did this, and when Aaron
  stretched out his hand with the staff and struck the dust of the
  ground, gnats came on people and animals. All the dust throughout the
  land of Egypt became gnats. But when the magicians tried to produce
  gnats by their secret arts, they could not.
  
  Since the gnats were on people and animals everywhere, the
  magicians said to Pharaoh, "This is the finger of God." But Pharaoh's
  heart was hard and he would not listen, just as the Lord had said.
I don't have my notes on hand but the bible contains multiple examples of Satan performing God like signs to fool Gods people. The book of Revelations is the obvious example this, but there's more.

As far as men performing magic, you also had Bar Jesus.

Long story short, although it's not exactly a popular opinion, Satan is illustrated as a being with similar (although lesser) powers as God, and it has been written that he has and will use these powers through mankind to gather people to him.

Satan is illustrated as having powers on a similar level as the Angel Michael which makes sense as he was a great angel (even though Satan was/is  dark on the whole), but in regards to the first answer these powers are not of earthly origins, nor can they be assumed to he bound by earthly restrictions (physics, etc).