Abstract factorization theorems with applications to idempotent factorizations