Cryptocurrencies have this somewhat undesirable property of being volatile. This volatility arises because the market is still trying to determine the price of the asset as measured against a well known currency like the US dollar. Most of the times, the volatility occurs because the asset isn’t as liquid as most other currencies or asset classes.
Stablecoins are designed to track the value of another (mostly) well known currency or asset. They are able to achieve this either algorithmically or via a backing by the underlying asset. When the peg is determined algorithmically, trading bots are employed to trade the asset such that they are able to maintain the required peg.
When there is the backing of an underlying asset, then the value is determined by the ability to redeem the stablecoin for the underlying asset itself. If such were backed by US dollar cash reserves (for example), then it is believed that the value will mirror the convertibility of the stablecoin for US dollars.