The <<repeat>> macro works asynchronously, so things after it will be displayed immediately.
You can fix your code like this:
<<set $value to 0>><span id="value">$value OK</span>
<<silently>><<repeat 0.125s>>
<<set $value to $value + 32>>
<<if $value <= 640>>
<<replace "#value">>$value OK<</replace>>
<<else>>
<<replace "#done">>It works!<</replace>>
<<stop>>
<</if>>
<</repeat>><</silently>>
<span id="done"></span>
Also, using <span> or <div> instead of <p> should keep it from ending up with a ton of blank space between elements.
Hope that helps! :-)