It's just inference that is unable to infer what to collect() into and what to sum() up. If you nudge type inference a bit, your second example will compile, too:
pub fn square_of_sum(n: u32) -> u32 {
let num: u32 = (1..n + 1).collect::<Vec<_>>().iter().sum::<u32>().pow(2);
num
}