### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

1. Create a bucket with object locking enabled.
2. Enable versioning in this bucket.
3. Upload file with **key**.  Received **version1** for this file.
4. Put a legal hold lock on the file (  **key** - **version1**).
5. Upload another file with the same **key**.  Received **version2** for this file.
6.  Put a legal hold lock on the file (  **key** - **version2**).
7. Remove the legal hold lock from the first version of the file  (  **key** - **version1**).
8. Try to delete the first version of the file (  **key** - **version1**) -> get An error occurred (AccessDenied) when calling the DeleteObject operation: Access Denied.


The script would run successfully if we change the order of commands (basically remove versions  of the file in reverse order):
(We have one file with version1 and version2, both locked)

- First, remove the lock from the version2.
- Delete version2.
- Remove the lock from version1.
- Delete version1.

### Expected Behavior

After the legal hold lock removed (Status=OFF) from the first uploaded version of the file, files should be accessible for deletion by its key and version.

### How are you starting LocalStack?

With the `localstack` script

### Steps To Reproduce

```
#!/bin/bash

echo -e "\033[0;32mCreate two text files\033[0m"

echo "Some text version 01..." > example-v1.txt
echo "Some text version 02..." > example-v2.txt

echo -e "\033[0;32mCreate bucket\033[0m"
awslocal s3api create-bucket --bucket my-bucket-001 --create-bucket-configuration LocationConstraint=ap-southeast-2 --region ap-southeast-2 --object-lock-enabled-for-bucket

echo -e "\033[0;32mEnable versioning\033[0m"
awslocal s3api put-bucket-versioning --bucket my-bucket-001 --versioning-configuration Status=Enabled

echo -e "\033[0;32mUpload first version of the file\033[0m"
version1=$(awslocal s3api put-object --bucket my-bucket-001 --key 123456789 --body example-v1.txt | jq -r '.VersionId')

echo -e "\033[0;32mPut lock on the version1 of the file\033[0m"
awslocal s3api put-object-legal-hold --bucket my-bucket-001 --key 123456789 --version-id $version1 --legal-hold Status=ON

echo -e "\033[0;32mUpload second version of the file\033[0m"
version2=$(awslocal s3api put-object --bucket my-bucket-001 --key 123456789 --body example-v2.txt | jq -r '.VersionId')

echo -e "\033[0;32mPut lock on the version2 of the file\033[0m"
awslocal s3api put-object-legal-hold --bucket my-bucket-001 --key 123456789 --version-id version2 --legal-hold Status=ON

echo -e "\033[0;32mRemove lock from the version1 of the file\033[0m"
awslocal s3api put-object-legal-hold --bucket my-bucket-001 --key 123456789 --version-id version1 --legal-hold Status=OFF

echo -e "\033[0;32mDelete version1 of the file\033[0m"
awslocal s3api delete-object --bucket my-bucket-001 --key 123456789 --version-id $version1
```

### Environment

```markdown
- OS: macOS 13.3.1
- LocalStack: latest, 2.0.2, 2.0.3.dev
```


### Anything else?

_No response_
import re
import shutil
import tempfile
import time
from io import BytesIO
from operator import itemgetter
from typing import TYPE_CHECKING
from urllib.parse import SplitResult, parse_qs, quote, urlencode, urlparse, urlunsplit
from zoneinfo import ZoneInfo
import boto3 as boto3
import pytest
import 
import xmltodict
from boto3.s3.transfer import KB, TransferConfig
from botocore import UNSIGNED
from botocore.auth import SigV4Auth
from botocore.client import Config
from botocore.exceptions import ClientError
from localstack import config, constants
from localstack.aws.api.s3 import StorageClass
from localstack.config import LEGACY_S3_PROVIDER
from localstack.constants import (
    LOCALHOST_HOSTNAME,
    S3_VIRTUAL_HOSTNAME,
    TEST_AWS_ACCESS_KEY_ID,
    TEST_AWS_SECRET_ACCESS_KEY,
)
from localstack.services.awslambda.lambda_utils import (
    LAMBDA_RUNTIME_NODEJS14X,
    LAMBDA_RUNTIME_PYTHON39,