I suspect they are going to constantly happen, whether you are there or not, the size of the attack groups and the frequency most likely connected to the size, the bigger and more prosperous a settlement is, the more important it is to set up npc guards and turrets, otherwise bandit attacks become busywork.
As far as we know until now, they are likely to happen randomly.
Although I still hope that settlement proximity to danger zones e.g. raider dens, deathclaw nest will affect the frequency of attacks on settlements...
I think they will happen while you're gone too, but the outcome depends on the number of defenses and weapons you got.
I would like to know if we will finally see some attacks on normal settlements. Everywhere are Raiders, but we never actually see them "raid" anything...