When do the sizes of conjugacy classes and squares of degrees of irreps give the same partition for a finite group?
My standard rant about "what can we say about $G$": what we can say about $G$ is that the two partitions are the same. If the questioner doesn't find that a helpful answer then they might want to consider the possibility that they asked the wrong question ;-)
But as to the actual question: "is $G$ forced to be abelian?", the answer is no, and I discovered this by simply looping through magma's database of finite groups. Assuming I didn't make a computational slip, the smallest counterexample has order 64, is the 73rd group of order 64 in magma's database, which has 8 representations of degree 1, 14 representations of degree 2, 8 elements in the centre and 14 more conj classes each of order 4.
Letting the loop go further, I see counterexamples of size 64, 128, 192 (I guess these are just the counterexamples of size 64 multiplied by Z/3Z) and then ones of order 243 (a power of 3). So I guess all examples I know are nilpotent. Are they all nilpotent? That's a question I don't know the answer to.
@Marty Isaacs: There exist non-nilpotent groups whose conjugacy class sizes are all squares. For example, let $G$ be Magma's 93rd group order 540. It has class sizes 1,4,9. Indeed, |G|=15*1+30*4+45*9. Also $|Z(G)|=15$ and $G/Z(G)$ is centerless. Thus G is non-nilpotent, and each conjugacy class size is a square.
This is not an answer, but more of an extended comment. It seems that the first one to raise this question was E. Bannai Association schemes and fusion algebras. (An introduction), J. Algebr. Comb. 2, No. 4, 327-344 (1993). The motivation was to find examples of when a certain matrix attached to a group association scheme is unitary (which is the case for "naturally occuring" association schemes). This happens precisely when the irreducible characters and conjugacy classes of the finite group can be paired up such that the size of the conjugacy class is the square of the corresponding character degree.
On p. 341 Bannai mentions that M. Kiyota has proved (using the CFSG) that this property does not hold for any non-abelian simple group. This shouldn't be too hard; as Jim Humphreys has noted, the case of simple groups of Lie type follows from the existence of the Steinberg character, whose degree equals the order a Sylow $p$-subgroup, hence the square of its degree cannot divide the order of the group. For simple alternating groups, it is easy to find conjugacy classes which are not squares, and for the sporadic groups one can explicitly check whether the condition holds in each case.
Bannai also mentions that Kiyota "conjectures that $G$ must be nilpotent if the condition is satisfied", so Kevin Buzzard's question has been asked before.
An interesting development that gives some support to the conjecture that these groups are nilpotent is this paper:
Andrus, Ivan; Hegedűs, Pál; Okuyama, Tetsuro, Transposable character tables and group duality., Math. Proc. Camb. Philos. Soc. 157, No. 1, 31-44 (2014). ZBL1330.20007,
where it is shown that every transposable group is nilpotent. Transposable groups are finite groups $G$ whose character table has the property that its transpose (viewed as a matrix) is, up to multiplication by suitable diagonal integer matrices on each side, equal to the character table of some other finite group $G^T$. Moreover, $G$ is called self-dual if it is isomorphic to $G^T$ (there are other, equivalent, definitions). By definition, self-dual groups satisfy the condition that conjugacy class sizes are the squares of corresponding character degrees (i.e., that the two partitions in the OP agree). Thus, at least self-dual groups are nilpotent. However, I think there exist non-self-dual groups satisfying the condition that the two partitions agree, so in general Kiyota's conjecture seems to be open.