First version is simply multiplying same object. There are no n
different lists here. All are the same list.
count = [[]] * (len(nums) +1)
print(count)
[[], [], [], []]
We can easily see this by printing these lists` id. They are exactly same. So if you append new element let's say on the first list, it'll appear in others too. Because they are same.
print(f"first - {id(count[0])}")
print(f"second = {id(count[1])}")
count[0].append(1)
print(count)
first - 4310957440
second -4310957440
[[1], [1], [1], [1]]
On the second version, you generate new lists and they are different. You can check yourself by printing the ID values.
count = [[] for i in range(3+1)]
print(count)
[[], [], [], []]
print(f"first - {id(count[0])}")
print(f"second = {id(count[1])}")
first - 4310956160
second -4310940416