Attacks with sameside castling often happen when one player allows the other to get too much development on the side his king is on, or allows him to get a strong center and/or space advantage on the side of the opponents king. There is a whole section on this in the book The King in Jeopardy by alburt and palatnik