I want to switch my front and back brakes I want to switch my brakes to have the front brake be on the right and the rear on the left?  How do I detach the cables and reattach to the opposite lever?
Assuming you have cable operated brakes, the basic answer is you have to detach the cables at the brake calipers, and pull the cables out of the housings through the levers. The levers hold the cable via a boss swaged onto the end of the cable, so that’s the only way to get the cables out. You can then switch which levers the the front and housing rear housings run to and re-thread the cables.
Cable strands often get unraveled by the pinch bolts that hold the cables on the calipers which makes the cables impossible to thread back through the housings, so new cables from the outset are a good idea.
You may encounter difficulties with switching the housings between levers depending on the existing housing routing.
You also need to know how to re-adjust the brake calipers when you re-attach the cables, but good quality guides are easily found on the web.
If you have hydraulic operated brakes things are more complicated. Hoses can be swapped but you have to deal with avoiding spilling hydraulic fluid and bleeding both brakes afterwards.