Both large and small drill variants can only be attached at the base third of the drill (e.g. the 3 x 3 x 2 furthest away from the business end of the drill head for the small drill). As a result the drill heads will always extend forwards, and it is good design to position the rest of the ship components behind the profile of any drills you have (so as to not have any "wings" get sheared off while mining).
To use the drill, activate it and then push it into the material you wish to mine. As the drill bits grind into the ore, the mined material will be deposited into the internal inventory space of the drill. If this space is not sufficient (on realistic settings, 3,375 L on small ships and 23,437.5 L on large ships/stations), it can be augmented by connecting the drill to a Conveyor system and the drill will automatically send push requests for the ore into it. This is necessary for larger setups to extend the time that the drill can be used before emptying.
Due to the spinning drill heads, not all ore will be deposited in the drill; some loosened rocks will float away into space. To compensate for this, Gravity Generators and/or Collectors can be added to a sophisticated setup. This same spinning motion will adversely affect the stability of lighter ships; this can be combated by adding weight to your ship, either with Heavy Armor blocks or more compact Artificial Mass blocks.
The small ship drill variant is rather weak, and has a tendency to be destroyed when rammed into things, including asteroids. Therefore, caution is advised when mining with the small drill, lest the block is destroyed from ramming it into the asteroid too hard.