What is the aerodynamic centre and how does it relate to the pitching moment?
A pitching moment is every moment acting around the lateral axis. Since a moment is the combination of a force and a lever arm, the magnitude of the moment depends on the choice of reference point, the point around which the pitching moment is defined. For flight mechanics, it helps to choose the center of gravity for all pitching moments, because then the weight force will not add a pitching moment of its own. Also, the center of gravity is special because this is the point around which the airplane rotates while in flight. 

I guess you mix up aerodynamic center and center of pressure. For me, it helps to use the term "neutral point" instead of aerodynamic center. Why?

Center of pressure describes clearly what it is: If you integrate all the pressures acting perpendicularly to the airflow, the resulting force acts in the center of pressure, just like all masses are summed up in the center of gravity (which, therefore, should be better called the center of mass).

In contrast to the center of mass, this center of pressure is not fixed, but moves when the angle of attack changes. If the airfoil has positive camber, the center of pressure moves forward with increasing angle of attack. If you now move your point of reference away from the center of pressure, you need to replace the lift force by the combination of the lift force and a moment (cogging torque). The motion of the center of pressure is such that at one point the cogging torque is constant regardless of angle of attack and lift. This is the aerodynamic center or neutral point, and I think "neutral point" describes much better what it is: The one point where the cogging torque behaves neutrally regarding angle of attack changes.

The real reason for this name is that static longitudinal stability is neutral (neither positive nor negative) if the center of gravity falls on the neutral point.

In stable flight the pitching moment around the center of gravity has to be zero; otherwise the airplane will display an accelerating pitch motion. To zero the pitch moment, the center of pressure is shifted onto a vertical line through the center of gravity. This shifting can be done by adding or subtracting lift at the tail, which in turn is done by adjusting the elevator deflection or the stabilizer incidence (if the plane has a moveable stabilizer)

Background

In potential flow theory, lift can be calculated as the linear superposition of a contribution from camber and one from angle of attack. While the camber-related part of lift is constant, the angle-of-attack related part varies linearly with this parameter. The center of pressure of the camber part is somewhere at mid-chord (details depend on the camber line; with a Joukowski airfoil the center of pressure is precisely at mid chord). The center of pressure of the angle-of-attack dependent part is at the quarter chord (the center of the area below the chordwise Birnbaum distribution of lift). The important part is the self-similarity of Birnbaum distributions for different angles of attack: The center of pressure of the angle-of-attack dependent part is constant.

Since lift at zero angle of attack is solely from camber, the center of pressure is at around mid chord and moves forward towards the quarter chord point as angle of attack increases. The cogging torque of the camber-related lift contribution around the quarter chord point is also constant, and since the angle-of-attack dependent part of lift has its center of pressure in exactly this quarter point, it will not add a pitching moment of its own at this point. Ergo, the cogging torque of lift in potential flow is constant if the reference point is the quarter chord point.

Fun fact: The center of pressure will move into infinity as the angle of attack is reduced to the zero-lift angle of attack.