### Apache Airflow version

2.6.2

### What happened

All tasks were run 1 time. The try number is 2 for all tasks

### What you think should happen instead

Try number should be 1 if only tried 1 time

### How to reproduce

Run a task and use the UI to look up try number

### Operating System

centos

### Versions of Apache Airflow Providers

_No response_

### Deployment

Virtualenv installation

### Deployment details

_No response_

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

try_count = ti.prev_attempted_tries if ti.prev_attempted_tries != 0 else ti.try_number
            task_dict = alchemy_to_dict(ti) or {}
            task_dict["end_date"] = task_dict["end_date"] or timezone.utcnow()
            task_dict["extraLinks"] = dag.get_task(ti.task_id).extra_links
            task_dict["try_number"] = try_count
            task_dict["execution_date"] = dttm.isoformat()
            task_dict["run_id"] = dag_run_id
            tasks.append(task_dict)
        tf_count = 0
        try_count = 1
        prev_task_id = ""
        for failed_task_instance in ti_fails:
            if not dag.has_task(failed_task_instance.task_id):
                continue
            if tf_count != 0 and failed_task_instance.task_id == prev_task_id:
                try_count += 1
            else:
                try_count = 1
            prev_task_id = failed_task_instance.task_id
            tf_count += 1
            task = dag.get_task(failed_task_instance.task_id)
            task_dict = alchemy_to_dict(failed_task_instance) or {}
            end_date = task_dict["end_date"] or timezone.utcnow()
            task_dict["end_date"] = end_date
            task_dict["start_date"] = task_dict["start_date"] or end_date
            task_dict["state"] = TaskInstanceState.FAILED
            task_dict["operator"] = task.operator_name
            task_dict["try_number"] = try_count
            task_dict["extraLinks"] = task.extra_links
            task_dict["execution_date"] = dttm.isoformat()