There are a couple of factors here that you need to consider.
First of all, increasing Z does mean that there are more particles in the nucleus; however, you're also adding electrons to the systems as well. Electrons dictate the size (i.e. volumen) of the atom, so the size of the atom could increase with increasing Z, which would mean that fewer atoms could fit into the same volume. To use your example, the covalent radius of Os is 144 pm; the covalent radius of U is 196 pm. So just from this property alone, you would expect more Os than U atoms to pack into the same volume.
There is another factor to consider as well: the crystal system of the solid. At standard temperature and pressure, atoms for different elements in the solid state pack into different arrangements, which are called crystal systems. Some of these are much more efficient than others. For example, there are three variants of the cubic crystal system: primative, body-centered, and face-centered. From Wikipedia:
Assuming one atom per lattice point, in a primitive cubic lattice with
cube side length a, the sphere radius would be a⁄2 and the atomic
packing factor turns out to be about 0.524 (which is quite low).
Similarly, in a bcc lattice, the atomic packing factor is 0.680, and
in fcc it is 0.740. The fcc value is the highest theoretically
possible value for any lattice, although there are other lattices
which also achieve the same value, such as hexagonal close packed and
one version of tetrahedral bcc.
Now, depending on which crystal system the atoms in the solid take, you could get more or less atoms per unit volume. Unfortunately, determining which crystal system is favored for different elements is not straightforward, and requires some knowledge of the bonding between the atoms and other factors.