There's a short grace period (currently 3 days) after a subscription ends. If you fix your billing within that window, you keep your number. After the grace period, the number is released and can't be recovered.
If your subscription renewed but the number still shows as expired, contact support — sometimes it's a display issue we can correct.