Compatibility first
A DDR4 motherboard cannot use DDR5 sticks, and a DDR5 motherboard cannot use DDR4 sticks.
Speed is not the only number
Capacity, latency, channel layout, CPU support, and motherboard configuration all affect memory behavior.
How to check
Use your motherboard model or a local hardware report to confirm memory generation, installed capacity, and configured speed.