The answers can probably only be found through historical sources and methods,
First, the answer to your second question.
You are watching: Why are there 31 days in july and august
The current calendar that most of the western world uses is Gregorian Calendar1, which is an improvement over Julian Calendar, which itself was an improvement over Traditional Roman Calendar.
Now, on to the first question.
Generally months with 31 and 30 days come in alternate fashion except for July and August which are consecutive. So why do they both have 31 days?
To answer this, we need to first look into the aramuseum.org of Roman Calendar. The first Roman calendar attributed to legendary Romulus had 10 months, and it started from Martius, i.e. the month we call March. And that can still be seen in the modern calendar today. September, October, November, and December are 9th, 10th, 11th and 12th months respectively, but Sept comes from Latin for 7, Oct is for 8, and so on.
After that, there were a couple of (minor) modifications to the Roman Calendar before the advent of Julian Calendar. At that time, there were 12 months, with Iunarius and Februarius, new months added before Martius. And yet, an ordinary year had 355 days, however, a tropical solar year, i.e. the period of Earth"s revolution around the Sun, is about 365.25 days. Therefore, before this time, Romans used to add a month called Mensis Intercalaris of 27/28-days between Februarius and Martius to balance this. (the detailed scheme can be seen in the wikipedia article on Julian Calendar).
To adjust this, the calendar was greatly overhauled under the reign of Julius Caesar. One of the consequences of this reform was Quintilis (Quint - 5; so now the 7th month), which already had 31 days, retained 31 days; and Sextilis (Sex - 6; so now the 8th month), which earlier had 29 days, gained a boost of 2 days and now had 31 days.If one is curious, the net change was January (Iunarius), Sextilis (August), and December gained 2 days each, whereas Aprilis (April), Iunius (June), September, and November gained 1 day each.
Now for the names of these months. After the death of Julius Caesar, Quintilis was renamed to Julius in his honor, which is the origin of July. Similarly, Sextilis was renamed to Augustus in the honor of then reigning emperor Augustus.
See more: Is -8 A Rational Number ? Is Negative 8 Rational Or Irrational
Interestingly, subsequent emperors Tiberius, Caligula, Domitian and Commodus (unsuccessfully) tried to rename September after themselves, but failed.
1 Technically, current calendar - the UTC is a further modification of Gregorian Calendar, because a Leap Second is sometimes added, to keep the time of day close to mean solar time. But for all practical purposes, it"s not significantly different from Gregorian Calendar.