What has not been mentioned yet and what is essential to understand to answer your question is Ohm's Law, which describes current flow (power) in relation to voltage (music signal) and resistance (speaker load.)
https://www.fluke.com/en-us/learn/blog/electrical/what-is-ohms-lawSpeaker load varies with frequency, so the same speaker might show 8 ohm load to the amp at one moment then show a 4 ohm load to the amp another moment.
Its just like a car, in that the car presents a varying load to the engine depending on several different factors. Uphill/downhill, cold/hot air, coasting or floored accelerator, etc. The engine can make 300hp at 2000rpm and 500HP at 6000rpm. Varying load, varying output, same engine.
A big misunderstanding among audiophiles who don't yet understand Ohms Law is that the amp forces its power on the speaker. "1000w amp will destroy a little Alpair 7 single driver speaker." No. The little driver is in control of the amp's power output. The amp will always send the amplified voltage requested by the volume knob, but the power level, and hence the loudness (and the damage) are determined by the impedance (load) of the speaker itself. The speaker demands the current according to the load. Load varies with frequency, so the power varies with frequency. Frequency varies with music, at least in some music.

The two power ratings given for the amp are just two points on the power curve of the amp, like power/rpm graph for an engine. When the music signal is 1000Hz the speaker might have 8 ohm load and draw 300w at a certain voltage. But at that same voltage when the speaker is playing 50Hz signal the impedance drops to 4 ohms and the amp will be providing 500w at that instant. Same amp, same speaker, varying load. In a real-world ported speaker the impedance near the port resonance might vary hugely. Port tuned to 40Hz might have impedance of 2ohms at port resonance 40Hz and 60 ohms at 30Hz and 60Hz. So any bass music will present very complex power demand to the amp. Negative feedback helps the amp to instantly and accurately deliver the current demanded by the speaker to control the drivers and maintain low distortion acoustic signal.
The speaker load varies because it is a complex mechanical device with many interacting variable forces. The driver has its own impedance curve, but that is made more complex when installed in a box. Search "loudspeaker impedance curve" for example graphs of varying load of a speaker.
2 power ratings are intended to help you decide whether the amp can adequately power any speaker across its entire performance envelope. The 8 ohm and 4 ohm points on the power curve are given as an industry standard, but the generalized "8 ohm speaker" is never true, and the actual minimum impedance is never given. You have to ask for impedance curve to learn it, or search for a reviewers measurements, or measure it yourself with "DATS" device or similar.
Hope this helps! Ohms law not easy to grasp at first, as it can seem counterintuitive. But it is extremely useful to audiophiles.