Just like measuring objects in meters and feet, poetry has its own brand of measurement called metrical feet. A metrical foot consists of a specific number of accented and unaccented syllables. By choosing varying usage of dominant feet, poets can create rhythm and mood in their poetry.
The most common metrical foot is the iamb. The iamb creates a 'da-dum' sound, a pattern of unstressed syllable followed by a stressed syllable.
Trochee is a two syllable foot and is the opposite of the iamb. The trochee has a stressed syllable followed by an unstressed syllable, like 'paper'.
Anapestis a three syllable foot. It features two unstressed syllables followed by a stressed syllable. Very commonly used by Poe in most of his poems.
Your lines would be broken down into this metre::
"It was many and many a year ago,"-- (Anapest, Anapest, Anapest, iamb)
"In a kingdom by the sea"-- (Anapest, iamb, iamb)