Welcome to Dominion!
Piles running out is a normal feature of a Dominion game. It happens to Kingdom piles regularly (those where there are 10 cards of in the pile), and occasionally also to the basic Treasure piles like Copper (as in your case), Silver or Gold. It's even part of a game ending condition (3 piles running out). In that case, an instruction to gain a card of such a pile is ignored and doesn't happen.
But, your remark "(like market, for instance)" shows that you made a mistake (that probably lead to the Copper pile runinng out): Market does not say you gain a Copper, it says to add $1 (the usual text representation used for 1 coin symbol) to your current turn's 'money account'.
You can think of the game as having a money account for you (and others), that gets emptied at the start of a turn. If you play a Copper, $1 is added to it, similar $2 is added from a Silver and $3 from a Gold. It is from that money account that you pay for your cards when you buy them, not directly from the Copper or Silver. Similiarly, when you play Market, you draw a card, then your Action account is incremented by 1 Action (thats one of the other accounts I talked about above), then your Buy account is incremented by 1 Buy (yet another account) and finally your money account is increased by $1. No Copper changes hands for this! Similiarly, a Milita doesn't give you a Silver, it adds $2 to your money account.
In the base game, you can usually easily calculate how much money you have available by looking at the cards in play. But be aware of Throne Room, which may 'double' the effect of a card. In later expansions there exist cards that make this account system necessary, because cards from play can go elsewhere, so the simple "look at what you have in play" wouldn't work any more.
Again, welcome to Dominion and have fun playing!