An object P is projective if, for any pair of objects A and B, and any epic morphism f from A to B, and any morphism g from P to B, there is at least one morphism h from P to A such that hf = g.
If the category admits free objects, and if epic is the same as onto, every free object is projective. If P is free, follow its generators to B, and then take preimages under f. It doesn't matter which preimages you choose. You now have a map from the generators of P into the elements of A. This map defines a morphism h from P to A. The composition hf gives a morphism from P to B, and this morphism agrees with g, at least on the generators of P. Yet if morphisms agree on the generators of a free object, they are the same. A morphism h has been constructed, the diagram commutes, and P is projective.
An object J is injective if, for any pair of objects A and B, and any monic morphism f from A to B, and any morphism g from A to J, there is at least one morphism h from B to J such that fh = g.
A free object need not be injective. Consider the category of abelian groups. Set J = A = B = Z. Clearly J is a free object. Let f map 1 to 2, and let g map 1 to 1. Since fh always maps 1 to an even number, it cannot equal g.