How can Monero be both anonymous and transparent at the same time?

Monero is "private, optionally transparent". By default, you can get very little information from Monero (you can know that a transaction occurred, but not whence, how much and whither).

But you can decide to give one particular person access to your balance by providing this person a viewkey, a specific string. For the moment, support is limited to addresses, since this wallet is the only one able to take advantage of viewkeys and MyMonero doesn't yet allow reading a address (such as an address created with simplewallet). But later, support will be extended to any wallet and addresses.

Another optional transparency feature, hinted at in the original whitepaper but not implemented yet, is auditable addresses.

Finally, we have also considered other methods of allowing for transparency on specific transactions. People want to be able to selectively prove payments on demand and generally open up to transparency in a controlled manner, without everything being linkable and traceable to the rest of their transactions.

See also this comment by Riccardo Spagni/fluffypony on reddit

I'd argue that there is another option. If I may demonstrate: Monero currently implements cryptographically sound transactional unlinkability and untraceability. However, it allows individuals to (completely optionally) give their "view key" to a select few, or to the government, or even publish it somewhere.

A view key can be used to reveal all transactions for an account. This means that companies could still be audited, charities could make their accounts publicly visible, and parents could see what their kids are spending the money on. Additionally, details of a transaction can be revealed via a similar mechanism on a per-transaction basis.

So the option I alluded to earlier is this: there already exists a cryptocurrency that has privacy by default, transparency optional. Governments wouldn't need to outlaw it, as law enforcement could still be given the tools to investigate illicit transactions (although they'd need to ask for the person's viewkey first, but that's no different than asking for someone's password to reveal incriminating evidence on their computer).

Viewkey infographic: