The attacks, reminiscent of those blamed on migrants in German cities during New Year’s Eve celebrations in 2015, shocked many Indians, since Bengaluru, home to many well-educated professionals, is regarded as safer for women than New Delhi.