There are two mirroring-related options in System Preferences > Displays:
At the bottom of all tabs there is "Show mirroring options in the menu bar" which, as it says, controls whether the icon appears in the menu bar.
Slightly above that, in the Arrangement tab only, there is "Mirror Displays" which is the option that actually turns on mirroring.
Which do you have turned on?
If you have the options icon displaying, you can also turn on mirroring by selecting "Mirror Builtin Display" from the menu that drops from that icon.
The Arrangement tab is also where you tell the MBP how the iMac display relates to the MBP display spatially (to the right, to the left, higher, lower).
None of this is dependent on the external display being an iMac; they work that way with other displays.
I don't have an iMac to test, but I think the iMac's keyboard and mouse are supposed to "go dead" in Target Display Mode. It's acting as a display, not a display + keyboard + mouse. (I have read that it also processes its own background tasks.)