Constricted by its medieval walls, Barcelona was suffocating – until unknown engineer Ildefons Cerdà came up with a radical expansion plan. Rival architects disparaged him, yet his scientific approach changed how we think about cities