Why was "State" and "state" written in this code? What's the difference?

Screenshot (51)

State is an enum, which is a common type of data on languages.
Enumerated type - Wikipedia.

Enums are one way to create a user-defined type in Solidity. They are explicitly convertible to and from all integer types but implicit conversion is not allowed. The explicit conversion from integer checks at runtime that the value lies inside the range of the enum and causes a failing assert otherwise. Enums needs at least one member.
Types — Solidity 0.5.3 documentation

So the state is a variable which it’s type is the enum State. state can only have a State value.