The previously checked checked-boxes in the mat table are not being counted when we select a new one. The entire checkbox column selection which is handled by a single checkbox which is in the header doesn't take into account of the newly checked or unchecked data.
To solve this we have to pass the index position in selection in the component.ts file:
Ex :
selection = new SelectionModel<PeriodicElement>(true, [this.dataSource.filteredData[1]);