The Moon and Sun act together or in opposition to cause the tides that we see. Gravitational attraction of the Moon and the Sun causes the tides but not how most people think. Most people think that the Moons gravitational attraction pulls the water on Earth towards the Moon thereby causing the tides. But if this were THE reason we have tides then we would only have one high tide on Earth when in fact there is a high tide on two points on Earth at the same time all the time.
So What Does Cause the Tides?
If the Earth was the only heavenly body the gravitational attraction of the Earth would be the same everywhere and would be constant everywhere. Everywhere meaning on the surface of the Earth. This would result in no tides. However, the Sun and Moon both exert a gravitational force on the Earth. These forces are relatively weak and we aren’t sensitive enough to notice. But they are strong enough to alter the gravitational center of the Earth.
Look at it this way. If you where at the center of a large mass in space. You would be pulled towards it. If you where to get inside of it and travel to the center you would be pulled equally in every direction. You would then be weightless. This point is the gravitational center of the object we will now call Earth. Now, since the other object, the Moon also pulls on us we would no longer be weightless at the center of the Earth, although it would be extremely small the Moon would be pulling on us.
As we moved toward the Moon we would no longer be at the center of the Earths gravitational pull so it would start to pull on us. Once you reach a point where the pull of the Earth is now countering the pull of the Moon then you would again be weightless. This point exist in real life inside the Earth closer to the surface than the true center of the Earth. You must remember that even though the Moons pull on you is small the force exerted on the Earth is much larger because the Earth is much more massive.
The Earth and Moon both orbit this “center of mass”. This orbital motion causes the Earth to experience a centrifugal force on the side away from the Moon, which forces the ocean in the direction away from the Moon! So the centrifugal force forces water to a high tide on the one side of the Earth while the gravitational pull of the Moon causes a high tide on the other side of the Earth. As the Earth spins on its axis, a given seaside location will experience a high tide when the Moon is at its closest, and then another one about ~12 hours later when it is on the other side of the Earth from the Moon.
Everyone knows that the Earth is orbited by the Moon once per day, right. Wrong. The Moon orbits the Earth once every 27 days, 7 hours, 43 minutes. The Moon appears to orbit the Earth once per day because the Earth rotation occurs once every day. So if the Moon were to stay exactly opposite the Sun all the time then the tides would occur twice every 24 hours. But since the Moon is slowly moving in a near circle around the Earth it throws of the time a bit each day. The alternation of high and low tides is caused by the daily (or diurnal) rotation of the Earth with respect to these two tidal humps and two tidal depressions.
So now you ask why do we have tidal difference cycle every 28 days. If the only large bodies around were the Moon and the Earth then all high tides would be the same intensity regard less of the where the Moon was in its rotational cycle around the Earth. But just as the Moon exerts a gravitation force on the Earth, so does the Sun. This same procedure we did with the Earth and Moon also exist between the Earth and the Sun. The Suns force is weaker than the force of the Moon because of its much greater distance from the Earth.
When a straight line can be draw from the Moon through the Earth and to the Sun then the Sun and Moons forces are working together. But when the Moon and Sun are at right angles to each other with respect to the Earth then their forces are working against each other. So as you would expect the tides are strongest(highest) when they are working together and weakest when they are working against each other. These two tides are known as spring tide(strongest) and neap tide (weakest).
So there you have it, the largest factors that give us tides. There are many other factors that affect the given strength of a particular tide such as Moon distance, it’s not constant, and many others. But they are not nearly as important. Hope this helps clear up some misconceptions and helps explain why we have tides.
Now if you have understood all that (OR NOT) read on to understand why we have different kinds of tides in different places on Earth which seems to contradict everything you have learned so far.