for the M2 Pro processor:
Simultaneously supports full native resolution on the built-in display at 1 billion colors and:
Up to two external displays with up to 6K resolution at 60Hz over Thunderbolt, -OR- one external display with up to 6K resolution at 60Hz over Thunderbolt and one external display with up to 4K resolution at 144Hz over HDMI
One external display supported at 8K resolution at 60Hz or one external display at 4K resolution at 240Hz over HDMI
for the M2 Max processor:
Simultaneously supports full native resolution on the built-in display at 1 billion colors and:
Up to four external displays: Up to three external displays with 6K resolution at 60Hz over Thunderbolt
-AND- one external display with up to 4K resolution at 144Hz over HDMI
Up to three external displays: Up to two external displays with 6K resolution at 60Hz over Thunderbolt and one external display with up to 8K resolution at 60Hz or one external display with 4K resolution at 240Hz over HDMI
Thunderbolt 4 digital video output
Support for native DisplayPort output over USB‑C
HDMI digital video output
Support for one display with up to 8K resolution at 60Hz or 4K resolution at 240Hz
>> so you have the ports, just plug them in.