As commonly defined, it's a simple command, "stop", but actually it's more like “STOP!” or “Stop doing that NOW!” or “Stop everything you’re doing and listen to me!” or “You are so wrong, and on so many levels, you’re going to have to stop while I explain!”. “Avast!” has become metasyntactic Old Salt seasoning, like “Arr!”, to be used indiscriminately to give a “pirate” or “naval” or simply “nautical” flavor to an utterance, often expanded to “Avast me hearties!” or the like.
In reality, on a pirate ship, you would almost never hear this expression used, except by the captain, or a senior officer, and that in some dire emergency (like trying to strike a match against a powder keg). The ordinary expression is a comparatively mild “That’ll do.”
If that sounds a lot like Patrick Stewart trying to talk down a hostile alien, or Jimmy Carter ordering lunch in Harlem, you’re right. Nautical vocabulary does sound excessively polite and formal on dry land, and for purely practical reasons: in order to get a vessel to port safely, you have to, somehow, deal with each other. Even if you’re doing so with gritted teeth, you’re still in close quarters, surrounded by water, and have no other place to go, often for weeks at a time, with nothing in particular to look at, and no other company but each other.
On the other hand, at the best of times, sometimes you may want to head off disaster with a quick, sharp, unmistakable word that isn’t used for anything else.
So, if someone decides to throw the word at you, stop doing what you’re doing, look clueless, and ask “What’s wrong?” When they look clueless, repeat some or all of the above, for extra Pirate points!