The max number of stations for SoftAP is a runtime setting available in Arduino.
ESP32 arduino WiFi library and esp8266 ESP8266WiFi library have it as last parameter in softAP() function which starts the SoftAP.
bool softAP(const char* ssid, const char* passphrase = NULL,
int channel = 1, int ssid_hidden = 0, int max_connection = 4);
esp8266 arduino doc
max_connection - optional parameter to set max simultaneous connected
stations, from 0 to 8. Defaults to 4. Once the max number has been
reached, any other station that wants to connect will be forced to
wait until an already connected station disconnects.
ESP32 SDK doc
uint8_t max_connection Max number of stations allowed to connect in,
default 4, max 10