Spanish Prime Minister Pedro Sánchez accepted the election defeat but vowed his party will return to government sooner than expected.