To become a mercenary, you need to make a mercenary contract with one of the factions. This will allow you to fight their enemies and participate in sieges, but you will not receive any fiefs like you would if you were a vassal.
To make a contract you must ask a vassal of the faction that you want to join if they have a task. There is quite a high chance that he will ask you to become a mercenary, which you can then accept.
Mercenary contracts last for 30 days in Warband, and can be renewed for another 30 days. In With Fire & Sword, the initial contract is 90 days, though renewing it will still be for 30 days. Mercenaries will be paid a random amount every week.