ISLAMABAD, Pakistan — A powerful earthquake rattled parts of Pakistan, India and Afghanistan on Sunday, shaking buildings and houses and causing panic in several cities.