The Advertising Standards Authority said the companies did not do enough to prevent under-16s seeing the content.
New rules governing children’s advertising online came into force last July, adding to rules already in place for TV ads.
The adverts featured on the companies’ websites, apps or social media.
In its ruling, ASA banned Cadbury’s use of a storybook titled The Tale Of The Great Easter Bunny on its website, which featured children hunting for eggs.
Chewits had four Facebook posts banned which featured Chewie the Chewitsaurus in a number of campaigns.
And a so-called advergame app called Squashies World, where players match pairs of Squashies by flicking them towards each other, was also banned.
Caroline Cerny of the Obesity Health Alliance said: “Whilst today’s rulings should be celebrated, the complaints demonstrate the blatant ways in which the food and drink industry attempts to exploit loopholes in the rules.”
ASA chief executive Guy Parker said: “The ban on HFSS [high in fat, salt or sugar] ads in children’s online media is working, but it’s important that we enforce it rigorously.
“These rulings show that we’re doing that and will help advertisers understand where we’re drawing the line.”
Mondelez, which owns Cadbury, said it would now “build upon our longstanding commitment to not market directly to children under the age of 16”.
Swizzels, which makes Squashies, said the advergame it created was not designed to appeal to children and did not “in any way” encourage children to eat sweets.
Chewits producer Cloetta said its Chewitsaurus was not “developed to target under-16s” and was instead targeted at “parents and young adults”.
Separately, YouTube star Zoella and Pointless Blog, run by her partner Alfie Dayes, were not found to have broken the ASA rules, after advertising the confectionary brand Ferrero.
The body found reasonable steps had been taken to target ads appropriately, and only a small portion of the the channel’s viewers were under-16.