The Hadith dealing with the salah of women in mosque is related to a time when women were free from the corruption of casting unwanted looks, while the narration from Hadhrat Umar (RA) related to a time when this thing started in mosques. Some rulings change as per the situation. Therefore, both the narrations are alright as per their age and time, there is no contradiction between the two.
Allah knows Best!
Darul Uloom Deoband