When you're using Swift on the command line, it's always (currently) targeting the OS that you're own. Swift only recently started including the capabilities for cross compilation (you can read up the details of the evolution proposal that's been accepted to support this: https://github.com/apple/swift-evolution/blob/main/proposals/0387-cross-compilation-destinations.md), which is probably the best documentation on what's to come - but that doesn't help you currently.
In the meantime, if you want to target macOS 14.0 explicitly for a swift package, open the Package.swift in Xcode - it'll allow you to select a specific target and build for that target.
Nothing wrong with how you pinned it, but worth being aware that platforms stanza in package.swift is specifying the minimum platform that your code should be pinned to (SupportedPlatform | Apple Developer Documentation). in your example, your package wouldn't compile on macOS 12 or 13. If that fits your needs, run with it!