Many things could go wrong when a new feature or functionality is being developed. It may turn out that the business may change their mind and this feature will be no longer needed. If tests are being automated while the feature is also being developed then the tests may need to be updated many times. Automation tests should be developed only when the build is stable i.e. after sanity tests have been performed.
Once the automated test is created, it is then added to the regression test suite to be run as next features are being developed.
Note that the test automation process is exactly the same as the test process.
This means that test cases will be selected for automation and test scripts will be created during the test design activity. And those tests will be executed during the test execution activity.