How is the number of poles in a DC machine chosen ?

The number of poles in a DC machine is chosen such that the frequency of the induced voltage in the armature is between 25 Hz to 50 Hz. 

Using the formula
dc machine formula no of poles

Thus if the speed of the machine is 1000 rpm with 4 poles, the frequency would be 33.33 Hz.

This frequency refers to here is the frequency of the induced emf in the armature.  The DC machine as such does not have any frequency.  The alternating voltage induced in the armature is converted into direct current by means of the brushes and the commutator.