Why is the voltage of a capacitor equal to the voltage of a battery connected it?
If we disconnect the capacitor from the circuit we get this circuit: 







simulate this circuit &ndash; Schematic created using CircuitLab

Let us close our circuit (12V battery and two resistors) in the black-box. 
We only have a access to A and B terminals.
And now let us try to find out what is inside the box, without opening the black-box. 

What can we do?
Well, we can measure the voltage across AB terminals.

And this voltage happens to be equal to Vth = 16V (24V * R2/(R1+R2))

We also can connect external load resistor and measure the corresponding voltage and current. But we are brave enough and we shot-out A and B terminals.
And measure the short-circuit current Isc = 6A (24V/R1)

Based on only those two measurements we can draw the following conclusion.
Our black-box is seen by the outside world as an ideal 16V voltage source with internal resistance equal to

Rth = Vth/Isc = 16V/6A = 2.667Ω (Rth = R1||R2)

So, we can remove our black-box from the circuit. 
And we replace the black-box with his equivalent circuit. The 16V ideal voltage source with 2.667Ω internal resistance. 







simulate this circuit

And I hope that now you can see that our capacitor will see this equivalent circuit. And this is why capacitor stops charging when the voltage across the capacitor reaches 16V. 

Later on, you will be introduced to the Thevenin's theorem. It will help you understand this stuff better.