Many lyrics work with a variety of melodies because the underlying structure of the set of melodies is similar.
My synagogue just had a "Broadway" bar mitzvah where the young man set our traditional prayers (which we do usually sing) to melodies from various Broadway showtunes. Worked great. (This particular synagogue has a history of changing up melodies anyway.)
One famous crossover is the words of the theme of Gilligan's Island (TV sitcom) sung to the tune of Stairway to Heaven.
Most songs are in 4/4 or 3/4 time. Meaning each measure has 4 beats or 3 beats, which can be divided up in different ways. You can also do other times, such as 2/4 or 6/8.
In music, a time signature tells you the meter of the piece you’re
playing. Composers decide the number of beats per measure early on and
convey this information with a time signature.
The two numbers in the time signature tell you how many beats are in
each measure of music. A piece with a time signature of 4/4 has four
quarter note beats; each measure with a 3/4 meter has three quarter
note beats; and each measure of 2/4 time has two quarter note beats.
A time signature of 4/4 meter does not mean that each measure has only
four quarter notes. It means each measure has only four beats. These
beats may contain half notes, quarter notes, eighth notes, rests,
whatever the composer wants, but all note and rest values must combine
to equal no more or less than the top number (or numerator) of the
time signature. (ref)
Choose a common time for your lyrics, along with a fairly standard rhythm. The more flexible the cadence and points of emphasis within them, the more likely your lyrics will fit multiple melodies. If you have many long words that must be pronounced with certain emphasis to be understood, that will limit the melodies you can use.