@NIKHILA NETHIKUNTA , Since I am using dotnet framework 4.8, the solution was to specify the authentication as Active Directory Default within the connection string and also remove the unwanted below code as its taken care internally.
var credential = new DefaultAzureCredential();
var tokenRequestContext = new TokenRequestContext(new[] { "https://database.windows.net/.default" });
var token = credential.GetToken(tokenRequestContext);
connection.AccessToken = token.Token;