Why has Spain's PM called a snap election?

Why has Spain's PM called a snap election?
his series of measures to tackle the housing crisis was defeated in parliament on Friday