I found when I was searching for a car this past year, the Elantra was not too comfortable seating wise. I'm 6'1" and the depth of the seats caused discomfort as opposed to the Mazda 3 seats. I ended up getting the 2017 2.5L Mazda 3 hatchback, even though it has 15 HP less than Elantra sport because it rides/handles much more proactively as opposed to the elantra.
If the entertainment system is a consideration and you're an iphone/android system user, Hyundai cars have Android Auto / Apple Carplay. Mazda doesn't have this available yet, and there is no confirmed notice that it will be available for Mazda.
Storage wise, the hatchback will win out hands down opposed to the elantra.
Gas mileage efficiency wise, the Elantra sport at 200 HP is about 1.5 -2 mpg more efficient than the 185 HP Mazda 3 Hatchback. But take into consideration that the hatchback is heavier too.
Price wise the Elantra will be winner as opposed to the 2.5L Mazda if you're looking for more power.
As I've not been on the Elantra forums, I do not know the ongoing, if any, reliability or consistent problems with the car.
With the Mazda I can tell you, the newer cars have a softer paint, hence rougher road conditions can be detrimental to the Mazda 3. This is one of the more persistent anecdotal complaints found on the forum. Check the TSB subforum for a better idea for outstanding issues. Powertrain wise, compared to other manufacturers, the Mazda is pretty reliable and there have been no exceptional wide spread issues noted in this generation of Mazda 3s (2014 onwards).