The 2 biggest causes of cannibalism are
lack of protein, and
overcrowding.
Chickens try to control flock size to match feed/protein supplies. If there is a shortage of
feed or protein, they will try to resolve the issue by eliminating 'the weak'. Eggs are a known source of protein, and they can't fight back. Obvious choice for controlling flock size.
As John Elliot points out, boredom can also be a factor. A cut up winter squash will keep them occupied all day long.
Artificial lighting is another potential cause. We don't often hear of it because it is normally only practiced by the bigger commercial operations, where the birds are caged, and life expectancy of the birds is not a concern. (When the cost of a replacement chick is about equal to the daily cost of feeding a non-producer, the birds get rotated out about the time they molt their first feather.)
If egg eating is a problem (it rarely is), and cannot be otherwise resolved, it's time for chicken salad.