Agile Testing Concepts - Test automation being part of the sprint

Often functional test automation (UI test automation, REST test automation) gets created in the next sprint after the feature has been completed and sometimes even released to production. The reason for this is that the many think a feature needs to be fully implemented before test automation is created. Another reason is that there is not enough time in the current sprint and creating automation is therefore pushed to the next one.