Joint wars are something you take advantage of.
Talk to any civ that has not denounced you and click make a deal and see who they are willing to joint war with you for. Naturally the more friendly they are the greater the range and higher the willingness.
There does seem to be a random factor involved so there is no guarantee but as long as its on that list you sometimes have to pay them to do it.
The advantages of a joint war are
1. You get +5 for "We fought a joint war together". This degrades one point every 20 turns so is a pretty nice short and medium term diplomatic modifier.
2. You get to declare the joint war against an enemy without any warning. So you get to perform a surprise war with the penalties of a formal war. As I understand it this penalty also affects the penalty for each city taken.
3. You can joint war with a civ way over the map, you can see that gorgo is running away with the game attacking lots of people and then when they stop war, find someone they denounced and declare a joint war against her and watch her go into revolt.
Now turning that around, its likely just what the AI is doing to you....
1. making friends at your expense
2. getting the jump on you in the "best possible taste"
3. Tiring you out if you look like winning
Normally in a joint war one of the two protagonists is close enough to raid and pillage if you have troops doing nothing. They declare peace. Then look at the size of the other civs armies in the victory screen and grow your larger than theirs and once I think at about 120% they will likely pay you to stop making pointless troops.
If I am just having fun I often have a couple of privateers. These are great as with the right card getting +50 science for raiding a mine is nice, let alone plundering trade routes and just generally causing havoc.