How the number is obtained
The amount at risk is your balance times the percentage you chose. It is the only decision genuinely under your control before entry: neither the market nor the broker changes it.
The size then comes out of one division: amount at risk ÷ (stop distance in pips × pip value per unit). The pip value is converted into your account currency at the current rate.
Exposure and leverage are not decoration. A very tight stop produces a huge size: the risk stays as intended, but the exposure can exceed what the broker will finance — and liquidation then comes long before the stop.