The RandomHash action in the Community Commons module in the Marketplace can generate a UUID.
You can also add an After Create action to call this and set an attribute when you create your object.
I hope this helps.
If you want UID to be unique and not generated every time you read the object, you need to not create calculated attribute.
UID should be stored.
And then in Before Create/After Create event microflow you can generate unique code and assign it to UID.
This way Microflow will be called once and UID will not be regenerated.