Fish have the simplest type of vertebrate heart, a systemic circulation system which has only two chambers in the heart: an atrium that collects blood from the body, and a ventricle that pumps blood through the gills and directly to the rest of the body. This produces a gradient of oxygenated to deoxygenated blood across the whole circulatory system, which limits how much oxygen fish can use.
Amphibians have a more complex heart, a pulmonocutaneous circulation system which has three chambers in the heart, two atria and one ventricle. One atrium collects blood from the lungs, while the other collects blood from the rest of the body. Then one ventricle pumps blood back out along two paths (separated by a ridge, but not completely prevented from mixing); one sends deoxygenated blood to the lungs and skin to be oxygenated, the other sends oxygenated blood to the rest of the body.
Crocodilian reptiles have a four-chambered heart, but with some unusual properties that distinguish it from the four-chambered heart of birds and mammals. They essentially have a hybrid system where one ventricle uses pulmonary circulation and the other uses systemic circulation. The heart shunts blood from the lungs directly to organs to support long periods underwater, and a hole called the foramen of Panizza between the two ventricles allows blood to be exchanged between them when necessary.
Finally, birds and mammals have a four-chambered heart and a pulmonary circulation system, where there is a totally separate atrium-ventricle circuit going into and out of the lungs that is distinct from the atrium-ventricle circuit into and out of the body. Blood in the heart does not mix, so it is fully-deoxygenated on one side (the atrium that receives blood from the body and the ventricle that pumps it to the lungs) and fully-oxygenated on the other (the atrium that receives blood from the lungs and the ventricle that pumps it to the body). This provides the most efficient oxygenation, allowing birds and mammals to have much higher metabolisms and thereby support endothermic body temperatures.