Why is wombat scat (feces) shaped like cubes?
I'm almost certain that your question is based on the press that Patricia J Yang's research is receiving (e.g., here and here).
Yang and her co-authors examined the structure and mechanics of some dead wombats to investigate this question further. They found that varying degrees of pressure in the latter portion of the wombat's intestines (in conjunction with a dehydrating of the fecal matter) led to the characteristic cube shape:
From their abstract:

In the final 8 percent of the intestine, feces changed from a liquid-like state into a solid state composed of separated cubes of length 2 cm. This shape change was due to the azimuthally varying elastic properties of the intestinal wall. By emptying the intestine and inflating it with a long balloon, we found that the local strain varies from 20 percent at the cube's corners to 75 percent at its edges. Thus, the intestine stretches preferentially at the walls to facilitate cube formation.


Why do this?
There seems to be two major reasons:

Mark territory
Attract mates

For example, see Wells 19891:

The rubbing of posts, logs and overhanging branches with their backs and rumps and deposition of faeces along trails may be a means of olfactory communication used in the maintenance of territories

One hypothesis is that by being square, the droppings don't roll as easily and therefore stay in the place that the wombat intended to mark.
I've also seen hypotheses about wombats stacking their square feces as some sort of signaling, but I couldn't find any reputable literature sources that make this suggestion.

1: Wells, R.T., 1989. Vombatidae. Fauna of Australia, 1, pp.755-768.