I have a UITableView contains one horizontal scroll UICollectionView in every cell like this
override func tableView(_ tableView: UITableView, cellForRowAt i
This happens because your collection view instances are reused with cells. Only 4 instances are being created and reused.
You can write your collectionview logic in your custom tableview cell and make custom cell as delegate and datasource of collectionview.