This happens primarily due to substandard workmanship. Sometimes this problem occurs even after few years. Generally surface of windows are smoother, therefore bonding with masonry gets gradually detached. There are many sealants and chemicals are now available in the market which can seal these gaps to prevent water seapage.